package org.htmlparser.sax;

import java.util.Vector;
import org.htmlparser.Attribute;
import org.htmlparser.Tag;
import org.xml.sax.Attributes;
import org.xml.sax.helpers.NamespaceSupport;

public class Attributes
  implements org.xml.sax.Attributes
{
  protected String[] mParts;
  protected NamespaceSupport mSupport;
  protected Tag mTag;

  public Attributes(Tag paramTag, NamespaceSupport paramNamespaceSupport, String[] paramArrayOfString)
  {
    this.mTag = paramTag;
    this.mSupport = paramNamespaceSupport;
    this.mParts = paramArrayOfString;
  }

  public int getIndex(String paramString)
  {
    this.mSupport.processName(paramString, this.mParts, true);
    return getIndex(this.mParts[0], this.mParts[1]);
  }

  public int getIndex(String paramString1, String paramString2)
  {
    int i = -1;
    Vector localVector = this.mTag.getAttributesEx();
    if (localVector != null)
    {
      int j = localVector.size();
      for (int k = 1; k < j; ++k)
      {
        String str = ((Attribute)localVector.elementAt(k)).getName();
        if (str != null)
        {
          this.mSupport.processName(str, this.mParts, true);
          if ((paramString1.equals(this.mParts[0]) & paramString2.equalsIgnoreCase(this.mParts[1])))
          {
            i = k;
            k = j;
          }
        }
      }
    }
    return i;
  }

  public int getLength()
  {
    return (this.mTag.getAttributesEx().size() - 1);
  }

  public String getLocalName(int paramInt)
  {
    this.mSupport.processName(getQName(paramInt), this.mParts, true);
    return this.mParts[1];
  }

  public String getQName(int paramInt)
  {
    String str;
    Attribute localAttribute = (Attribute)(Attribute)this.mTag.getAttributesEx().elementAt(paramInt + 1);
    if (localAttribute.isWhitespace())
      str = "#text";
    while (true)
    {
      return str;
      str = localAttribute.getName();
    }
  }

  public String getType(int paramInt)
  {
    return "CDATA";
  }

  public String getType(String paramString)
  {
    return null;
  }

  public String getType(String paramString1, String paramString2)
  {
    return null;
  }

  public String getURI(int paramInt)
  {
    this.mSupport.processName(getQName(paramInt), this.mParts, true);
    return this.mParts[0];
  }

  public String getValue(int paramInt)
  {
    String str = ((Attribute)(Attribute)this.mTag.getAttributesEx().elementAt(paramInt + 1)).getValue();
    if (str == null)
      str = "";
    return str;
  }

  public String getValue(String paramString)
  {
    this.mSupport.processName(paramString, this.mParts, true);
    return getValue(this.mParts[0], this.mParts[1]);
  }

  public String getValue(String paramString1, String paramString2)
  {
    return this.mTag.getAttribute(paramString2);
  }
}